<%--
 *  File:    KPIConfigMain.jsp
 *  @Author: TendyHu	
 *  Date:    2010/10/28
 *
 *  Copyright (C) 2000 - 2010 Oval Technologies, Inc.
 *  All rights reserved.
 *
 *  This software is the confidential and proprietary information of Oval
 *  Technologies, Inc. ("Confidential Information").  You shall not
 *  disclose such Confidential Information and shall use it only in
 *  accordance with the terms of the license agreement you entered into
 *  with Oval.
--%>


<%@ include file="/inc/SessionTimeout.inc"%>
<%@ page language="java"%>
<%@ page import="java.util.*"%>
<%@ page import="org.apache.log4j.Category"%>

<%@ page contentType="text/html;charset=UTF-8"%>
<%@ taglib uri="/WEB-INF/PageFlow.tld" prefix="PageFlow"%>
<%@ taglib uri="/WEB-INF/struts-logic.tld" prefix="logic"%>
<%@ taglib uri="/WEB-INF/oval-tag.tld" prefix="oval"%>
<%@ taglib uri="/WEB-INF/custom.tld" prefix="custom"%>



<% //--------------------------------------  setting logger --%>
<%
  Category cat = Category.getInstance("jsp.KPIConfigMain");
  //init param
  String strModuleName = "CRM";
  String privilegeCode = "p0101";
String contextPath = request.getContextPath();
%>
<%@ include file="/inc/Security.inc"%>
<%@ include file="/inc/PageDefault.inc"%>

<html>
<head>
<PageFlow:CheckPageFlow pageName="p_kpiconfigmain" />
<%--@ include file="/inc/CatchError.inc" --%>
<%
	//params 
	String paraIsDefault = "";
	String isTdNeed = "td-text";
	if("Y".equals(request.getParameter("info"))) {		
		isTdNeed = "need";
	}else if ("N".equals(request.getParameter("info"))) {
		paraIsDefault = "N";
	}
	String isNew = request.getParameter("isNew");
	  if("Y".equals(request.getParameter("isNew"))) {
			isNew = "Y";
		}else if ("N".equals(request.getParameter("isNew"))) {
			isNew = "N";
		}else  {
			isNew = null;
		}
  //params end
  
  HashMap performancekpiinfo = null;
  String valuePerformancekpiid = null;
  String dateOpt = null;
  performancekpiinfo = (HashMap)pageContext.getAttribute("performancekpiinfo");
	  if(performancekpiinfo != null&&performancekpiinfo.size()!=0) {
  		if(isNew.equals("Y")){
  			valuePerformancekpiid = JspHelper.filterNull( performancekpiinfo.get("performancekpiid") ).toString();
	  	}
		dateOpt = JspHelper.filterNull( performancekpiinfo.get("createdate") ).toString();
      }else {
	  	  performancekpiinfo = new HashMap();
		  performancekpiinfo.put("status","41");
		  performancekpiinfo.put("createdate",new java.sql.Date(System.currentTimeMillis()));
		  pageContext.setAttribute("performancekpiinfo",performancekpiinfo);
		  valuePerformancekpiid = "";
		  performancekpiinfo = (HashMap)pageContext.getAttribute("performancekpiinfo");		
      }
  
  HashMap userinfo = (HashMap)session.getAttribute("userinfo");
  
%>

<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<link rel="stylesheet"
	href="<%=contextPath%>/css/<%= strLanguageCode %>/main.css"
	type="text/css">
<script language="JavaScript"
	src="<%=contextPath%>/css/<%= strLanguageCode %>/script.js"></script>
<script language="JavaScript" src="<%=contextPath%>/js/ScriptLib.js"></script>
<script language="JavaScript">

function changeStatus()
{
  if(form.status1.value == -1)
  {
	  form.valuename.value = " ";
  }
  else
  {
	 // alert("status1 : " + form.status1.value);
    for (i = 0; i < form.status1.options.length; ++i)
    {
      var opt = form.status1.options[i];
      if (opt.selected)
      {
    	  form.valuename.value = opt.text;
      }
    }
  }
}

function changeProcessType()
{
  if(form.processtype.value == -1)
  {
	  form.groupname.value = " ";
  }
  else
  {
    for (i = 0; i < form.processtype.options.length; ++i)
    {
      var opt = form.processtype.options[i];
      if (opt.selected)
      {
    	  form.groupname.value = opt.text;
      }
    }
  }
}

function page_save()
{	
	if(!checkForm(form))   return;
	if(isEmpty(form.processname.value)) {
		alert("<%= message.getMessageDesc("VALUE_NOT_NULL",label.getLabelName("L_VisitProcessName",false)) %>");
		return;
	}
	if(isEmpty(form.status.value)) {
		alert("<%= message.getMessageDesc("VALUE_NOT_NULL",label.getLabelName("L_Status",false)) %>");
		return;
	}

	if( "Y" == "<%=paraIsDefault%>") {
		if(isEmpty(form.processtype.value)) {
		alert("<%= message.getMessageDesc("VALUE_NOT_NULL",label.getLabelName("L_Type",false)) %>");
		return;
		}
	}
	
	var frm = document.form;
	frm.actionname.value = "save";
	frm.target = "_parent";
	frm.submit();
}

function page_back()
{  
  parent.location.href = "VisitProcessSummary.jsp?<%= OvalTools.randomURL() %>&languagecode=<%= strLanguageCode%>";
}
</script>
</head>
<body leftmargin="0" topmargin="0" marginwidth="0" marginheight="0">
<table width="100%" cellspacing="0" cellpadding="0">
	<tr>
		<td class="summary_top"></td>
	</tr>
</table>
<table width="100%" cellspacing="0" cellpadding="0">
	<form name="form" method="post" action="<%=contextPath%>/Dispatcher"><input
		type="hidden" name="pagename" value="p_kpiconfigmain"> <input
		type="hidden" name="actionname"> <input type="hidden"
		name="languagecode" value="<%= strLanguageCode %>"> <input
		type="hidden" name="isNew" value="<%= isNew %>"> <%if(isNew.equals("Y")) { %>
	<input type="hidden" name="createdate"
		value="<%= OvalTools.getDate() %>"> <custom:hidden name="userinfo"
		property="orgid" scope="session" /> <%}%><custom:hidden
		name="performancekpiinfo" property="performancekpiid"
		value="<%=valuePerformancekpiid%>" />
	<tr>
		<td colspan="4" class="td_right" height="22"><a onclick="page_save()"><custom:button
			type="2" label="L_Save" border="0" tabindex="34" /></a> &nbsp;
	</tr>
	<tr>
		<td valign="top">
		<table border="1" cellspacing="0" bordercolorlight="#999999"
			bordercolordark="#FFFFFF" align="center" width="100%" cellpadding="1">
			<tr>
				<td colspan="4" class="deepblue-left" height="22"><img
					src="<%=contextPath%>/images/<%= strLanguageCode %>/quote.gif">
				&nbsp;
			</tr>
			<tr>
				<td class="need" width="110"><%= label.getLabelName("L_KPICode") + label.getLabelName("L_Colon") %></td>
				<td><custom:text name="performancekpiinfo" command="notnull"
					module="CRM" property="kpicode" label="L_KPICode" size="20" /></td>
				<td class="need" width="110"><%= label.getLabelName("L_KPIName") + label.getLabelName("L_Colon") %></td>
				<td><custom:text name="performancekpiinfo" command="notnull"
					module="CRM" property="kpiname" label="L_KPIName" size="20" /></td>
			</tr>
			<tr>
				<td class="td-text" width="110"><%= label.getLabelName("L_Department") + label.getLabelName("L_Colon") %></td>
				<%if(isNew.equals("N")) { %>
				<td><custom:write property="deptname" name="performancekpiinfo"
					nbsp="true" /></td>
				<custom:hidden property="deptid" name="performancekpiinfo" />
				<%}else{
        			boolean deptDisabled = true;
        			if(isNew.equals("Y"))deptDisabled = false;
        		%>
				<td>  <custom:select
					optionInnerTextKey="deptname" optionsName="alldepts"
					optionValueKey="deptid" property="deptid" 
					defaultValue="--------" defaultValueCost=" "
					disabled="<%=deptDisabled %>" />
					</td>
				<%} %>
				<td class="need" width="110"><%= label.getLabelName("L_JobName") + label.getLabelName("L_Colon") %></td>
				<td><custom:text name="performancekpiinfo" command="notnull"
					module="CRM" property="jobname" label="L_JobName" size="20" /></td>
			</tr>
			<tr>
				<td class="td-text" width="110"><%= label.getLabelName("L_MaxValue") + label.getLabelName("L_Colon") %></td>
				<td><custom:text name="performancekpiinfo" property="maxvalue"
					size="20" /></td>

				<td class="td-text" width="110"><%= label.getLabelName("L_MinValue") + label.getLabelName("L_Colon") %></td>
				<td><custom:text name="performancekpiinfo" property="minvalue"
					size="20" /></td>
			</tr>
			<tr>
				<td class="td-text" width="110"><%= label.getLabelName("L_CreateDate") + label.getLabelName("L_Colon") %></td>
				<td><custom:write name="performancekpiinfo" property="createdate"
					dataType="date" dataFormatName="dateformat" /></td>

				<td class="td-text" width="110"><%= label.getLabelName("L_Status") + label.getLabelName("L_Colon") %></td>
				<td><custom:write name="performancekpiinfo" property="status" /></td>
			</tr>
		</table>
		</td>
	</tr>
	<tr>
		<td class="summary_top"></td>
	</tr>
	<tr>
		<td height="49" class="td_center"><a onclick="javascript:page_back()"><custom:button
			type="1" label="L_Back" imgsrc="back.gif" border="0" style="width:60" /></a>
		</td>
	</tr>
	</form>
</table>
<%@include file="/inc/AlertError.inc"%>
</body>
</html>


